import {
  getRankings
} from '../service/api'
import {
  HYEventStore
} from 'hy-event-store'
 export const rankObj = {0: 'newRankings', 1: 'rankings', 2: 'originRankings', 3: 'upRankings'}
export default new HYEventStore({
  state: {
    rankings: [], // 热门 1
    newRankings: [], // 新歌 0
    originRankings: [], // 原创 2
    upRankings: [], // 飙升 3
  },
  actions: {
    async getRankings(ctx, index) {
      for(let i = 0; i<4;i++) {
        getRankings(i).then(e=> {
          const {playlist} = e
          ctx[rankObj[i]] = playlist
        })
      }
    }
  }
})